/*
 *d6_2_2.cpp
 * 2017年1月22日
 *jon
 */
#include<iostream>
using std::cout;
using std::endl;
using std::string;
void reset(int *ip);

string::size_type find_char(const string &s, char c,
		string::size_type &occurs) {
	auto ret = s.size();  //第一次出现的位置
	occurs = 0;
	for (decltype(ret) i = 0; i != s.size(); ++i) {
		if (s[i] == c) {
			if (ret == s.size())
				ret = i;  //记录c第一次出现的位置
			++occurs;      //出现的次数加 1
		}
	}
}

int main() {
	/*int n = 0, i = 42;
	 int *p = &n, *q = &i; //p指向n;q指向i
	 *p = 42;
	 cout << " n :\t " << n << endl;
	 p = q;

	 cout << "i \t" << i << endl;*/

	/*int i = 42;
	cout << "地址" << &i << endl;
	reset(&i);
	cout << "i = " << i << "地址" << &i << endl;*/


    string s("ccldc");
    string::size_type ctr;
	auto index  = find_char(s,'o',ctr);

	return 0;
}

void reset(int *ip) {
	*ip = 0; //改变指针ip所指的对象的值
	ip = 0;   //只改变ip的局部拷贝,实参未被改变
}
